<template>
  <div class="dialog-overlay" v-if="modelValue" @click="closeDialog">
    <div class="dialog-content" @click.stop>
      <div class="dialog-header">
        <h3>紧急事件详情</h3>
        <span class="close-btn" @click="closeDialog">×</span>
      </div>
      <div class="dialog-body">
        <div class="info-item">
          <span class="label">事件等级：</span>
          <span class="value" :class="event.level">{{ event.level }}</span>
        </div>
        <div class="info-item">
          <span class="label">事件时间：</span>
          <span class="value">{{ event.time }}</span>
        </div>
        <div class="info-item">
          <span class="label">事件地点：</span>
          <span class="value">{{ event.location }}</span>
        </div>
        <div class="info-item">
          <span class="label">具体描述：</span>
          <span class="value">{{ event.description }}</span>
        </div>
        <div class="info-item">
          <span class="label">推荐预案：</span>
          <span class="value file-link" @click="previewFile">{{ event.plan }}</span>
        </div>
        <div class="info-item">
          <span class="label">当前状态：</span>
          <div class="status-buttons">
            <button 
              v-for="status in statuses" 
              :key="status"
              :class="{ active: event.status === status }"
              @click="updateStatus(status)"
            >
              {{ status }}
            </button>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { defineProps, defineEmits } from 'vue'

const props = defineProps({
  modelValue: Boolean,
  event: {
    type: Object,
    required: true
  }
})

const emit = defineEmits(['update:modelValue', 'update-status'])

const statuses = ['去处理', '处理中', '已处理']

const closeDialog = () => {
  emit('update:modelValue', false)
}

const updateStatus = (status) => {
  emit('update-status', status)
  closeDialog()
}

const previewFile = () => {
  // 后续实现文件预览功能
  console.log('预览文件:', props.event.plan)
}
</script>

<style lang="scss" scoped>
.dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.dialog-content {
  background-color: #0f1325;
  border-radius: 8px;
  width: 500px;
  max-width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.dialog-header {
  padding: 15px 20px;
  border-bottom: 1px solid rgba(0,194,255,0.3);
  display: flex;
  justify-content: space-between;
  align-items: center;

  h3 {
    color: #00c2ff;
    margin: 0;
    font-size: 18px;
  }

  .close-btn {
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    &:hover {
      color: #00c2ff;
    }
  }
}

.dialog-body {
  padding: 20px;

  .info-item {
    margin-bottom: 15px;
    display: flex;
    align-items: flex-start;

    .label {
      color: #00c2ff;
      width: 100px;
      flex-shrink: 0;
    }

    .value {
      color: #fff;
      flex: 1;

      &.file-link {
        color: #00c2ff;
        cursor: pointer;
        text-decoration: underline;
        &:hover {
          color: #fff;
        }
      }

      &.high {
        color: #ff4d4f;
      }
      &.medium {
        color: #faad14;
      }
      &.low {
        color: #52c41a;
      }
    }

    .status-buttons {
      display: flex;
      gap: 10px;

      button {
        padding: 5px 15px;
        border: 1px solid #00c2ff;
        background: transparent;
        color: #00c2ff;
        border-radius: 4px;
        cursor: pointer;
        transition: all 0.3s;

        &:hover {
          background: rgba(0,194,255,0.1);
        }

        &.active {
          background: #00c2ff;
          color: #0f1325;
        }
      }
    }
  }
}
</style> 